const mongoose = require("mongoose");

// 连接数据库
mongoose.connect("mongodb://localhost:27017/happy-chat", {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

const db = mongoose.connection;
db.on("error", (err) => {
  console.log("连接失败", err);
});

db.once("open", () => {
  console.log("连接成功");
});

module.exports = {
  User: require("./user"),
};
